<template>
  <div class="hminput" v-if="imgconnent.length!==0">
    <div class="inner">
      <span style="margin-top: 5px; margin-left: 10px">
        <van-icon name="arrow-left" />
      </span>
      <span style="margin-left: -140px" @click="$router.go(-1)">返回</span>
      <span style="margin-left: -50px">图片详细</span>
      <span></span>
    </div>
    <div class="nppem">
      <h2>{{ imgconnent[0].title }}</h2>
      <p>
        <span>{{ imgconnent[0].add_time }} &nbsp;&nbsp;&nbsp;</span>
        <span>{{ imgconnent[0].click }}次播放&nbsp;&nbsp;</span>
        <span>分类：{{ imgconnent[0].category }}</span>
      </p>
    </div>
    <div class="getimg">
      <img :src="item.src" alt v-for="(item, index) in img" :key="index" />
    </div>
    <div class="connent">
      <p v-html="imgconnent[0].content"></p>
    </div>
    <div class="pinlun">
      <van-field
        v-model="message"
        rows="2"
        autosize
        label="评论:"
        type="textarea"
        maxlength="100"
        placeholder="请输入评论内容"
        show-word-limit
      />
    </div>
    <div class="button">
      <van-button type="primary" size="large" class="aa" @click="published">发表评论</van-button>
    </div>
    <div class="list">
      <div class="top">
        <h2>评论列表</h2>
        <span>{{ this.total }}条评论</span>
      </div>
      <div class="user" v-for="(comment, index) in getneirong" :key="index">
        <p>{{ comment.content }}</p>
        <div class="username">
          <span style="color: blue">{{ comment.user_name }}</span>
          <span style="color: #999" class="right">{{ comment.add_time }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getpinglun, getcomment } from "./../apis/img/img";
export default {
  data() {
    return {
      message: "",
      getneirong: [],
      total: "",
    };
  },
  methods: {
    published() {
      // console.log(111);
      getcomment({ artid: this.idd, content: this.message }).then((res) => {
        if (res.data.message == "评论提交成功") {
          this.message = "";
          getpinglun({ artid: this.idd, pageindex: "1" }).then((res) => {
            // console.log(res);
            this.getneirong = res.data.message;
            this.total = res.data.total;
          });
        }
      });
    },
  },
  props: {
    img: {
      type: Array,
    },
    imgconnent: {
      type: Array,
    },
    idd: {
      type: String,
    },
  },
  mounted() {
    getpinglun({ artid: this.idd, pageindex: "1" }).then((res) => {
      // console.log(res);
      this.getneirong = res.data.message;
      this.total = res.data.total;
    });
  },
};
</script>

<style lang="less" scoped>
.hminput {
  padding-bottom: 60px;
  //  /deep/ .van-field__control{
  //    background-color: rgb(233, 229, 224);
  //  }
  /deep/ .van-field__label {
    font-size: 15px;
    text-align: center;
    // line-height: 3;
    color: chartreuse;
  }
  .inner {
    height: 50px;
    width: 100%;
    font-size: 20px;
    line-height: 50px;
    color: rgb(21, 75, 226);
    background-color: rgba(239, 239, 250, 0.5);
    align-items: center;
    display: flex;
    justify-content: space-between;
    box-shadow: 5px 5px 5px rgb(243, 241, 241);
    margin-top: 5px;
    margin-bottom: 5px;
  }
  .nppem {
    // height: 100px;
    // border-bottom: 55px;
    margin-top: 15px;
    border-bottom: 2px solid #999;
    h2 {
      // margin-top: 5px;
      font-size: 20px;
      font-weight: 700;
      padding: 0 10px;
      color: dodgerblue;
    }
    p {
      padding: 10px 10px;
      color: #999;
    }
  }
  .getimg {
    // height: 200px;
    width: 100%;
    display: flex;
    padding: 0 6px;
    // justify-content: space-between;
    // direction: rtl;
    justify-content: flex-start;
    margin-top: 10px;
    flex-wrap: wrap;
    img {
      margin-top: 20px;
      margin-right: 3%;
      height: 90px;
      width: 30%;
    }
  }
  .button {
    padding-bottom: 10px;
    border-bottom: 2px solid #999;
    .aa {
      width: 90%;
      color: rgb(255, 255, 255);
      background-color: dodgerblue;
      border-radius: 5px;
      margin-left: 5%;
      margin-top: 20px;
    }
  }
  .connent {
    margin-top: 40px;
    line-height: 1.35;
    text-indent: 2em;
  }
  .list {
    .top {
      display: flex;
      height: 50px;
      line-height: 50px;
      justify-content: space-between;
      padding: 0 10px;
      border-bottom: 2px solid #999;
      h2 {
        // padding-top: 5px;
        font-weight: 700;
      }
      span {
        color: #999;
        // padding-top: 25px;
      }
    }
    .user {
      padding: 5px 10px;
      border-bottom: 2px solid #999;
      p {
        margin-bottom: 10px;
        margin-top: 10px;
      }
      .username {
        display: flex;
        justify-content: space-between;
        margin-bottom: 15px;
        padding-top: 5px;
      }
    }
  }
}
</style>